﻿@*@model SMECustomerWebsite.Models.ViewModels.ProductHandbook.ProductHandbookCustomerChecklistViewModel*@
<div class="row">
    <div class="col-md-12">
        <div class="x_panel">
            <div class="x_title">
                <h2>@SMECustomerWebsite.Core.Resources.Resource.ProductHandbookByProductProgramTitle</h2>
                <ul class="nav navbar-right panel_toolbox">
                    <li>
                        <a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                    </li>
                </ul>
                <div class="clearfix"></div>
            </div>
            <div class="x_content">
                <div class="table-responsive">
                    <table id="checklist_document" class="custom_table table table-striped jambo_table bulk_action">
                        <thead>
                            <tr class="headings">
                                <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.ChecklistDocumentHeader.ToUpper()</th>
                                <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.ProgrammeProduct.ToUpper()</th>
                                <th class="column-title" width="30%">@SMECustomerWebsite.Core.Resources.Resource.StatusHeader.ToUpper()</th>
                                <th class="column-title last">@SMECustomerWebsite.Core.Resources.Resource.ActionHeader.ToUpper()</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <!-- End to do list -->
</div>
@section scripts
{

    <script src="~/scripts/tableeditable/dataTables.rowsGroup.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var table = $('#checklist_document').DataTable({
                bFilter: false,
                bInfo: false,
                bPaginate: false,
                "responsive": true,
                "bAutoWidth": false,
                "bServerSide": true,
                //"bProcessing": true,
                "sAjaxSource": '@Url.Action("ProductProgramData", "AdminChecklist")',
                "fnServerData": function (sSource, aoData, fnCallback) {
                    $.ajax({
                        "dataType": 'json',
                        "type": "POST",
                        "url": sSource,
                        "data": aoData,
                        "success": fnCallback
                    });
                },
                rowsGroup: [0],
                fixedHeader: true,
                "aoColumns": [
                            { "sName": "DATE OPEN", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false },
                            { "sName": "DATE OPEN", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false }],
                "columnDefs": [{
                    "sClass": "a-center ",
                    "aTargets": 2,
                    "mRender": function (data, type, full) {
                        if (data == true) {
                            return 'Đã tạo checklist';
                        } else {
                            return 'Chưa tạo checklist';
                        }
                    }
                }, {
                    "sClass": "a-center ",
                    "aTargets": 3,
                    "mRender": function (data, type, full) {
                        if (full[2] == true) {
                            return '<a class=\"btn btn-primary btn-xs\"  href=\"/AdminChecklist/QuestionChecklist?productid=' + full[3] + '\"><i class="fa fa-eye"></i></a>';
                        } else {
                            return '<a class=\"btn btn-primary btn-xs\" onclick=\"addInfoProduct(\'' + full[3] + '\');\"><i class="fa fa-plus"></i> </a>';
                        }
                    }
                }]
            });
        });
        function addInfoProduct(product) {
            $.ajax({
                url: '@Url.Action("AddInfoProduct", "AdminChecklist")',
                type: "POST",
                data: { proId: product },
                success: function (data_response) {
                    window.location.reload();
                }
            })
            return false;
        }
    </script>
}
